﻿<div ng-controller="itpController">
	<div class="wrapper border-bottom white-bg page-heading">
		<div class="col-lg-pull-12">
			<ol class="breadcrumb">
				<li>{{breadcrumb}}</li>
			</ol>
		</div>
	</div>
	<div class="form-horizontal row">
		<div class="form-group">
			<div class="col-sm-4">
				<label class="col-sm-4 control-label">状态</label>
				<div class="col-sm-8">
					<select class="form-control input-sm" ng-model="query.status">
						<option value="">全部</option>
						<option value="1">下载</option>
						<option value="2">已对账</option>
					</select>
				</div>
			</div>
			<div class="col-sm-4">
				<label class="col-sm-4 control-label">对账日期</label>
				<div class="col-sm-8">
					<div date class="input-group date">
						<input class="form-control input-sm" ng-model="query.start_date">
						<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
					</div>
				</div>
			</div>
			<div class="col-sm-4">
				<div class="col-sm-8">
					<div date class="input-group date">
						<input class="form-control input-sm" ng-model="query.end_date">
						<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-4">
				<div class="col-sm-offset-4 col-sm-12">
					<a class="btn btn-primary btn-sm" ui-sref="app.finance.itp(query)"><i class="fa fa-search"></i> 查询</a>
					<button class="btn btn-primary btn-sm" ng-click="add()"><i class="fa fa-plus"></i> 新增</button>
					<button class="btn btn-primary btn-sm" ng-if="query.pay_channel==1" ng-click="get_balance()" btn-loading="psdisabled" loading-text="处理中..." ng-disabled="psdisabled"><i class="fa fa-database"></i> 当前余额</button>
				</div>
			</div>
			<div class="col-sm-8">
				<div class="col-sm-12">
					<div class="form-control-static text-right">分润：{{model.merchant_amount+model.profit}} 高清：{{model.merchant_amount}} 利润：{{model.profit}} 
					<span ng-if="query.pay_channel==1">总额度：{{model.channel_total}} 当前余额：{{model.balance}}</span></div>
				</div>
			</div>
		</div>
	</div>
	<form name="_form" class="form-horizontal w5c-form" w5c-form-validate="itp_form.validateOptions" role="form" ng-if="itp_form.add" novalidate>
        <div class="form-group form-group-sm">
            <label class="col-sm-2 control-label">日期</label>
            <div class="col-sm-3">
                <div date class="input-group date">
					<input name="create_date" class="form-control input-sm" ng-model="itp_form.create_date" required>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
            </div>
        </div>
        <div class="form-group form-group-sm">
            <div class="col-sm-3 col-lg-offset-2">
				<input name="pay_channel" type="hidden" ng-model="itp_form.pay_channel=query.pay_channel">
                <button type="submit" class="btn btn-primary btn-sm" w5c-form-submit="code_file()" btn-loading="psdisabled" loading-text="生成中..." ng-disabled="psdisabled">生成文件</button>
            </div>
        </div>
    </form>
	<table class="table table-hover m-t-md">
		<thead>
			<tr style="background-color: #f7f7f9;">
				<th>日期</th>
				<th>文件</th>
				<th>支付金额</th>
				<th>代付金额</th>
				<th>费率成本</th>
				<th>结算成本</th>
				<th>余额</th>
				<th>分润</th>
				<th>高清</th>
				<th>利润</th>
				<th width="65">状态</th>
				<th width="65">详情</th>
			</tr>
		</thead>
		<tbody>
			<tr ng-repeat="item in model.rows">
				<td>{{formatDate(item.create_date,'yyyy-MM-dd')}}</td>
				<td>{{item.file}}</td>
				<td>{{item.pay_amount}}</td>
				<td>{{item.off_amount}}</td>
				<td>{{item.fee_cost}}</td>
				<td>{{item.settle_cost}}</td>
				<td>{{item.balance}}</td>
				<td>{{(item.merchant_profit+item.profit)| number : 6}}</td>
				<td>{{item.merchant_profit}}</td>
				<td>{{item.profit}}</td>
				<td>
					{{item.status==2?"已对账":""}}
					<button class="btn btn-primary btn-xs" ng-click="deal(item)" btn-loading="psdisabled" ng-if="item.status==1"
							loading-text="处理中..." ng-disabled="psdisabled">
						<i class="fa fa-search"></i> 对账
					</button>
				</td>
				<td>
					<a class="btn btn-primary btn-xs" href=""><i class="fa fa-cog"></i> 详情</a>
				</td>
			</tr>
		</tbody>
	</table>
	<div class="row">
		<div class="col-md-12">
			<uib-pagination total-items="model.total_result" items-per-page="model.size" ng-model="model.page" num-pages="model.total_pages"
							ng-change="search_page(model.page)" class="pagination-sm" boundary-links="true" boundary-link-numbers="true" max-size="20"
							previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></uib-pagination>
			<span class="pull-right" style="margin: 30px 0px 20px 0px">共{{model.total_result}} 当前：{{model.page}}/{{model.total_pages}}</span>
		</div>
	</div>
</div>
